/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Br.Com.Cds.Academia.Estoque;

import Br.Com.Cds.Academia.DAO.AcessoMySQL;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
 *
 * @author Pedro
 */
public class EstoqueControl {
    
    PreparedStatement pstm;
    ResultSet rs ;
    
    String cadastraestoque = "INSERT INTO ESTOQUE (CODIGO,ESTOQUE,ESTOQUEMINIMO)VALUES (?,?,?)";
    
    
    public void cadastrarEstoque (EstoqueBean estoque){
        try {
        AcessoMySQL mysql = new AcessoMySQL();
        pstm = (PreparedStatement) mysql.conectar().prepareStatement(cadastraestoque);
        pstm.setInt(1, estoque.getCodigo());
        pstm.setInt(2, estoque.getEstoque());
        pstm.setInt(3, estoque.getEstoqueminimo());
        pstm.executeUpdate();
        mysql.desconectar();
        
        } catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(null, "SQL EXCEPTION ! ERRO AO TENTAR CADASTRAR O ESTOQUE!","CDS ACADEMIA",JOptionPane.ERROR_MESSAGE);
        }
        
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}
